<?
/*
(*_*)gues1||id||status||text1$$text2(*_*)gues2||id||status||text
*/

$listguest= isset($_POST['listguest']) ? $_POST['listguest'] : array();
//listguest=idroom1|row||idroom1|row||

$arr=explode("||",$listguest);
$list=array();
for($i=0;$i<count($arr);$i++)
{
	$arr2=explode("|",$arr[$i]);
	$list['id'][$i]=intval($arr2[0]);
	$list['row'][$i]=intval($arr2[1]);
}

$sql_select="select * from ".$GLOBALS['first_table']."tblchat where iUserId='$userid' order by iChatId";
$rs=$dbsql->query($sql_select);

echo ".(*_*)";
while($rq=$dbsql->fetch_array($rs))
{
	
	$guest=$rq['cRoomName'];
	$id=$rq['iChatId'];
	$status=$rq['iStatus'];
	$text=$rq['cText'];
	$rowed=0;
	for($i=0;$i<count($list['id']);$i++)
	{
		if($id==$list['id'][$i])
		{
			$rowed=$list['row'][$i];
		}
	}
	$textarr=explode("$$",$text,$rowed+1);
	
	echo $guest;
	echo "||";
	echo $id;
	echo "||";
	echo $status;
	echo "||";
	echo $textarr[$rowed];
	echo "(*_*)";
}
exit();
?>